﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SimpleElectricalEquipment : MonoBehaviour,IElectricalEquipment
{
    [SerializeField] public PowerSupply power;
    [SerializeField] public bool isOpen = true;
    public virtual void Awake()
    {
        if (power == null)
        {
            isOpen = true;
            return;
        }
        power.AddEquipment(this);
        if (power.isOpen != isOpen)
        {
            if (power.isOpen)
            {
                Open();
            }
            else
            {
                Close();
            }
        }
    }
    public virtual void Open()
    {
        isOpen = true;
    }

    public virtual void Close()
    {
        isOpen = false;
    }

    public virtual void OnDestroy()
    {
        if (power == null)
            return;
        power.RemoveEquipment(this);
    }
}
